package net.lab1024.sa.admin.module.business.exam.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import net.lab1024.sa.admin.module.business.exam.domain.entity.ExamromaEntity;
import net.lab1024.sa.admin.module.business.exam.domain.form.add.ExamromaAddForm;
import net.lab1024.sa.admin.module.business.exam.domain.form.query.ExamromaQueryForm;
import net.lab1024.sa.admin.module.business.exam.domain.form.update.ExamromaUpdateForm;
import net.lab1024.sa.admin.module.business.exam.domain.vo.ExamromaVO;
import net.lab1024.sa.admin.module.business.exam.service.ExamromaService;
import net.lab1024.sa.base.common.domain.PageResult;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

@RestController
@Tag(name = "日历明细")
public class ExamromaController {

    @Resource
    private ExamromaService examromaService;

    @PostMapping("/examroma/queryPage")
    public ResponseDTO<PageResult<ExamromaVO>> queryPage(@RequestBody @Valid ExamromaQueryForm queryForm) {
        return ResponseDTO.ok(examromaService.queryPage(queryForm));
    }

    @PostMapping("/examroma/add")
    public ResponseDTO<String> add(@RequestBody @Valid ExamromaAddForm addForm) {
        return examromaService.add(addForm);
    }


    @PostMapping("/examroma/batchadd/{docEntry}")
    public ResponseDTO<String> batchAdd(@PathVariable Long docEntry,@RequestBody List<Long> addForms) {
        return examromaService.batchAdd(addForms,docEntry);
    }

    @PostMapping("/examroma/update")
    public ResponseDTO<String> update(@RequestBody @Valid ExamromaUpdateForm updateForm) {
        return examromaService.update(updateForm);
    }

    @PostMapping("/examroma/batchDelete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return examromaService.batchDelete(idList);
    }

    @GetMapping("/examroma/delete/{docEntry}")
    public ResponseDTO<String> batchDelete(@PathVariable Long docEntry) {
        return examromaService.delete(docEntry);
    }

    @GetMapping("/examroma/myInfo/{docEntry}")
    public ResponseDTO<ExamromaEntity> myInfo(@PathVariable Long docEntry) {
        return examromaService.myInfo(docEntry);
    }

    @GetMapping("/examroma/openExam/{docEntry}")
    public ResponseDTO<ExamromaEntity> openExam(@PathVariable Long docEntry) {
        return examromaService.openExam(docEntry);
    }

    @PostMapping("/examroma/submitExam")
    public ResponseDTO<String> submitExam(@RequestBody ExamromaEntity examromaEntity) {
        return examromaService.submitExam(examromaEntity);
    }

    @GetMapping("/examroma/querylist/{docEntry}")
    public ResponseDTO<List<ExamromaEntity>> querylist(@PathVariable Long docEntry) {
        return examromaService.querylist(docEntry);
    }




}
